package dd.prog2.exercises.set05;

/**
 * Places und Reihenfolge. Loesung fuer TSP
 */
public class Trip {
	private Place[] trip;
	private int i;
	private double route;

	public Trip(int i) {
		this.trip = new Place[i];
		this.i = 0;
		this.route = 0;
	}

	/*
	 * Ort zu Loesung hinzufuegen x, y - Koordinaten, i - index in tsp[]
	 */
	public void addPlace(Place p) {
		trip[i] = p;
		i++;
	}

	public void routeLength(double route) {
		this.route += route;
	}

	@Override
	public String toString() {
		String res = "";
		for (int i = 0; i < trip.length; i++) {
			if(i<(trip.length-1))
					res += trip[i].name + "-> ";
			else res += trip[i].name;
		}
		res += "\nLength: " + String.format("%.3f", this.route);
		return res;
	}
}
